import { globalIgnores } from 'eslint/config'
import {
  defineConfigWithVueTs,
  vueTsConfigs,
} from '@vue/eslint-config-typescript'
import pluginVue from 'eslint-plugin-vue'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import apiSuffixRule from './src/util/api-name-suffix'
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup

export default defineConfigWithVueTs(
  {
    name: 'app/files-to-lint',
    files: ['**/*.{ts,mts,tsx,vue}'],
  },
  globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),

  pluginVue.configs['flat/essential'],

  vueTsConfigs.recommended,
  {
    rules: {
      'vue/no-unused-components': 'error',
      'vue/component-name-in-template-casing': ['error', 'PascalCase'],
      'vue/no-v-html': 'error',
      '@typescript-eslint/no-explicit-any': ['off'],
      'vue/multi-word-component-names': 'off',
    },
  },
  // 自定义规则
  {
    files: ['src/api/*.{ts,tsx}'], // 指定路径
    plugins: {
      custom: {
        rules: {
          'api-name-suffix': apiSuffixRule,
        },
      },
    },
    rules: {
      'custom/api-name-suffix': 'error',
    },
  },
  skipFormatting
)
